package cn.easybuy.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import cn.easybuy.dao.BaseDao;
import cn.easybuy.dao.Easybuy_product_detailDao;
import cn.easybuy.entity.easybuy_product_detail;
import cn.easybuy.utils.DataSourceUtil;

public class Easybuy_product_detailDaoimpl extends BaseDao implements Easybuy_product_detailDao {

	public Easybuy_product_detailDaoimpl(Connection conn) {
		super(conn);
		// TODO Auto-generated constructor stub
	}

	@Override
	public easybuy_product_detail getProductIdDetail(int productId)
			throws SQLException {
		// TODO Auto-generated method stub
		String sql="SELECT `id`,`product_id`,`imgone`,`imgtwo`,`imgthree`,`imgdetail`,`specifications`,"+
				"`texture`,`date`,`place`,`packing`,`people` "+ 
				"FROM `easybuy_product_detail` "+
				"WHERE `product_id`=?";
		ResultSet rs=null;
		easybuy_product_detail detail=null;
		try {
			rs=this.executeQuery(sql, productId);
			while(rs.next()){
				detail =new easybuy_product_detail();
				detail.setId(rs.getInt("id"));
				detail.setProduct_id(rs.getInt("product_id"));
				detail.setImgone(rs.getString("imgone"));
				detail.setImgtwo(rs.getString("imgtwo"));
				detail.setImgthree(rs.getString("imgthree"));
				detail.setImgdetail(rs.getString("imgdetail"));
				detail.setSpecifications(rs.getString("specifications"));
				detail.setTexture(rs.getString("texture"));
				detail.setDate(rs.getString("date"));
				detail.setPlace(rs.getString("place"));
				detail.setPacking(rs.getString("packing"));
				detail.setPeople(rs.getString("people"));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw e;
		}finally{
			DataSourceUtil.closeAll(null, null, rs);
		}
		return detail;
	}

}
